﻿namespace MagicKey.Interfaces
{
    public interface IAccessManager
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string EncryptFileSym(string path, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string DecryptFileSym(string path, string key);

        /// <summary>
        /// </summary>
        /// <param name="fileOwner"></param>
        /// <param name="plainFileName"></param>
        string EncryptFileAsym(string fileOwner, string plainFileName);

        /// <summary>
        /// </summary>
        /// <param name="fileOwner"></param>
        /// <param name="fileOwnerPassword"></param>
        /// <param name="encryptedFileName"></param>
        string DecryptFileAsym(string fileOwner, string fileOwnerPassword, string encryptedFileName);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="plainText"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string EncryptStringSym(string plainText, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="plainText"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        string DecryptStringSym(string plainText, string key);

        /// <summary>
        ///     Authorize an access to file
        /// </summary>
        /// <param name="masterId">owner of a file</param>
        /// <param name="slaveId">user whom access will be atributed</param>
        /// <param name="uri">uri of a file</param>
        /// <returns></returns>
        bool AuthorizeAccess(int masterId, int slaveId, string uri);

        /// <summary>
        ///     Generate a 64 bits sysmetric Key
        /// </summary>
        /// <returns>a generate sysmetric key</returns>
        string GenerateSysmKey();

        /// <summary>
        ///     generate asymetric keys pair
        /// </summary>
        /// <returns>array of public and private key. first key in a array is a public key</returns>
        string[] GenerateAsymKeysPair();

        /// <summary>
        ///     Hash a password with MD5 Algorithm
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        string HashPassword(string password);

        /// <summary>
        ///     Generate a Salt
        /// </summary>
        /// <returns>a salt value</returns>
        string GenerateSalt();

        /// <summary>
        ///     Hash a hashed password and salt with MD5 Algorithm
        /// </summary>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        string HashHashedPasswordAndSalt(string password, string salt);

        /// <summary>
        ///     Verifi if a credential a valid
        /// </summary>
        /// <param name="password">username of user</param>
        /// <param name="username">uncryted password of user</param>
        /// <returns>true if credential is valid else false</returns>
        bool VerifyUserPassword(string username, string password);

        string GetEncryptedFilename(string sInputFilename);
    }
}